<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.pignest.hotel.beans.User" %><%@ page import="com.pignest.hotel.service.UserService" %>
<%@ page import="com.pignest.hotel.spring.Services" %><%@ page import="com.pignest.hotel.system.*" %>
<%@ page import="java.util.List" %><%@ page import="com.pignest.framework.util.Utils" %>
<%@ page import="com.pignest.hotel.beans.Duty" %>
<%
String contextPath = request.getContextPath();
int tabIndex = Utils.getInteger(request.getParameter("tabIndex"), 0);
User user = Hotel.getCurrentUser();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>我的值班 - <%=user.getName() %></title>
<link type="text/css" rel="stylesheet" media="screen" href="<%=contextPath%>/css/jquery-ui.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="<%=contextPath%>/css/hotel.css"/>
<script type="text/javascript" src="<%=contextPath%>/scripts/context.jsp"></script>
<script type="text/javascript" src="<%=contextPath%>/scripts/jquery.js"></script>
<script type="text/javascript" src="<%=contextPath%>/scripts/jquery-ui.js"></script>
<script type='text/javascript' src='<%=contextPath%>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=contextPath%>/dwr/interface/GlobalAjax.js'></script>
<script type='text/javascript' src='<%=contextPath%>/dwr/interface/DutyAjax.js'></script>
<script type="text/javascript" src="<%=contextPath%>/scripts/card.js"></script>
<script type="text/javascript" src="<%=contextPath%>/scripts/profile.js"></script>

<script type="text/javascript">
window.tabIndex = <%=tabIndex%>;
</script>
</head>
<body>

<object id="bdLockCard" classid="clsid:130D6F39-2FE2-45FB-92B3-AE73D5B2B4EC"  width="0" height="0"></object>
<div id="tabs">
	<ul>
		<li><a href="#tabs-1">个人资料</a></li>
		<li><a href="#tabs-2">修改密码</a></li>
		<%if (user.hasPermission("RECEPTION")){ %>
		<li><a href="#tabs-3">值班</a></li>
		<%} %>
	</ul>
	<div id="tabs-1">
		<form id="setting_form" onsubmit="return false;">
		<ul class="form">
			<li><label>工号</label> <%=user.getWorkNumber() %>&nbsp;</li>
			<li><label>真实姓名</label> <%=user.getName() %>&nbsp;</li>
			<li><label for="user_nickname">昵称</label> 
				<input id="user_nickname" maxlength="20" type="text" value="<%=Utils.showString(user.getNickName())%>"/>
			</li>
			<li><label>卡号</label> <%=Utils.showString(user.getCardNumber()) %>&nbsp;</li>
			<li>
				<label for="user_gender">性别</label> 
				<select id="user_gender" style="width:152px;">
<%
String[] genders = Global.getGenders();
for (int i=0; i<genders.length; i++) {
	String selected = genders[i].equals(user.getGender()) ? "selected='true'" : "";
%><option value="<%=genders[i]%>" <%=selected %>><%=genders[i]%></option>
<%}%>
				</select>
			</li>
			<li><label for="user_phone">电话</label> <input id="user_phone" maxlength="20" type="text" value="<%=Utils.showString(user.getPhone()) %>"/></li>
			<li><label for="user_birthday">出生年月</label>
				<input maxlength="20" id="user_birthday" type="text" value="<%=user.getBirthday2() %>"/>
				<label class="right">(yyyy-mm-dd)</label>
			</li>
			<li><label>上次登录时间</label> <%=user.getLastLoginTime2() %>&nbsp;</li>
		</ul>
		
		<div class="toolbar">
			<input id="submit_profile" type="button" value="-  保存  -" />
		</div>
		</form>
	</div>
	<div id="tabs-2">
		<form id="setting_form" onsubmit="return false;">
		<ul class="form">
			<li><label for="oldPassword">旧密码</label> 
				<input id="oldPassword" type="password" maxlength="32"/>
			</li>
			<li><label for="newPassword">新密码</label> 
				<input id="newPassword" type="password" maxlength="32"/>
			</li>
			<li><label for="repeat">重复新密码</label> 
				<input id="repeat" type="password" maxlength="32"/>
			</li>
		</ul>
		
		<div class="toolbar">
			<input id="submit_password" type="button" value="-  保存  -" />
		</div>
		</form>
	</div>
<%if (user.hasPermission("RECEPTION")){ %>
	<div id="tabs-3">
<%
	Duty duty = Services.getUserService().getDuty(user);
	if (duty == null) {
%>
	你目前不在值班. 若轮到您值班, 你可以开始新的值班, 但正常情况下你应该与当前正在值班的人交接后值班.
	<div class="toolbar">
		<button id="startDuty">开始新的值班</button>
		<button id="acceptDuty">从上一班交接</button>
	</div>
<%	} else {%>
	<div>
		<ul class="form">
			<li><label></label><%=user.getName()%>&nbsp;</li>
			<li><label>状态</label><%=duty.getStatus2() %>&nbsp;</li>
			<li><label>交接人</label><%=duty.getPreviousUser2() %>&nbsp;</li>
			<li><label>开始时间</label><%=duty.getStartTime2() %>&nbsp;</li>
			<li><label>结束时间</label><%=duty.getEndTime2() %>&nbsp;</li>
			<li><label>收支</label><%=duty.getAmounts() %>&nbsp;</li>
			<li><label>详情</label><a target="_blank" href="<%=contextPath%>/modules/admin/dutyLog.jsp?duty=<%=duty.getId()%>">查看</a> </li>
		</ul>
		<div class="toolbar">
<%		if (duty.getStatus()==Duty.STATUS_PAUSE){ %>
			<button id="resumeDuty">恢复值班</button>
<%		}else{ %>
			<button id="pauseDuty">暂停值班</button>
<%		} %>
			<button id="reserveMoney">预备金</button>
			<button id="passDuty">交接给下一班</button>
			<button id="withdraw">财务提款</button>
			<button id="refresh">刷新</button>
		</div>
	</div>
<%	}%>
	</div>
<%} %>
</div>

<div id="dialogs" style="display:none;">
<div id="selectUser" title="选择用户">
	<div id="utabs" style="overflow:hidden;">
		<ul>
			<li><a href="#utabs-1">密码</a></li>
			<li><a href="#utabs-2">刷卡</a></li>
		</ul>
		<div id="utabs-1" style="padding:5px;">
			<ul class="form">
				<li><label for="workNumber">工号</label><input type="text" id="workNumber" style="width:200px;"/></li>
				<li><label for="password">密码</label><input type="password" id="password" style="width:200px;"/></li>
			</ul>
		</div>
		<div id="utabs-2" style="padding:32px;">
			<input type="hidden" id="userId"/>
			<input type="hidden" id="cardNumber"/>
			<button id="creditCard" style="padding:11px 25px;">刷卡</button>
			<span id="userName"></span>
		</div>
	</div>
	<div id="amount" style="display:none;padding-left:9px;">
		<ul class="form">
			<li>
				<label for="withdraw">金额</label><input type="text" id="withdraw" maxlength="10"/>
			</li>
		</ul>
	</div>
</div>

<div id="reserveDialog" title="添加预备金">
	<div style="padding-left:9px;">
		<ul class="form">
			<li>
				<label for="reserve">金额</label><input type="text" id="reserve" maxlength="10"/>
			</li>
		</ul>
	</div>
</div>

</div>

</body>
</html>
